home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-21 | 2.5 KB | 65 lines | [TEXT/NTP1] |
- /*
- ** Newton Developer Technical Support Sample Code
- **
- ** Custom Route, a Newton 2.0 routing example
- **
- ** by J. Christopher Bell, Newton Developer Technical Support
- **
- ** Copyright © 1994-5 by Apple Computer, Inc. All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction. This sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. You are not
- ** permitted to modify and redistribute the source as "DTS Sample Code."
- ** If you are going to re-distribute the source, we require that you
- ** make it clear in the source that the code was descended from
- ** Apple-provided sample code, but that you've made changes.
- */
-
- constant kMyMainDataDefSym := '|myDataDef:customRoute:PIEDTS| ;
- constant kMyMainViewDefSym := '|myViewDef:customRoute:PIEDTS| ;
- constant kMyFrameViewDefSym := '|myFrameViewDef:customRoute:PIEDTS| ;
-
-
- // Get the cup icon
- OpenResFile(home & "pictures");
- DefConst('kCupIcon, GetPictAsBits("minRouteIcon", nil));
- CloseResFile();
-
-
- /*
- * This is a routing format which handles 'text and 'frame (despite the name, protoFrameFormat
- * handles both types. If you want to handle just 'frames, override the dataTypes slot with ['frame].
- *
- * This will be registered in the application installScript with RegisterViewDef(...).
- *
- * Note that we won't necessarily be able to view the item in the iobox unless we write a
- * NON-ROUTING viewDef for kMyMainDataDefSym so that it can be viewed in the iobox item viewer.
- */
- DefConst('kMyFrameRoutingFormat, {
- _proto: protoFrameFormat,
- title: "CustomRoute - picture choice",
- version: 1,
- symbol: kMyFrameViewDefSym,
- SetupItem: func(item, targetInfo)
- begin
- inherited:?SetupItem(item, targetInfo);
- /*If you have any "preprocessing" to do like set anything in the item or add
- * extra body slots like version slots, or extra data, you can do it here, but if you are
- * trying to actually prep visual shapes, do that in formatInitScript.
- *
- * Note that by calling inherited, we get the equivalent of:
- * item.body := targetInfo.target;
- * ...plus if the target is a soup entry alias, it resolves it...
- *
- * Only modify the item, not the target.
- */
-
- // set the title; note that the string will be editable by the user...
- item.title := "CustomRoute item: " & datentime(time());
-
- item;
- end,
- textScript: func(fields, target)
- clone(target.data); // our target.data should always be plain text
- });